Skip to content

The adoption pass reads the runs inside its window, not the whole archive (#1607) - #1630

Merged
suleimansh merged 1 commit into
mainfrom
1607-archive-window
Aug 21, 2026
Merged

The adoption pass reads the runs inside its window, not the whole archive (#1607)#1630
suleimansh merged 1 commit into
mainfrom
1607-archive-window

Conversation

@suleimansh

Copy link
Copy Markdown
Contributor

Closes #1607 — its last open note.

The cost

The cloud-work adoption pass wants the settled web runs of the last 48 hours. It asked the store for every archived run the project has ever had, parsed each one, and then let waitingRuns drop everything outside the window. That ran every ten minutes, forever, against a directory that only grows.

The change

An archived run is filed as <id>.json, and an id is the run's start time — so the filename already dates the record. listAgents takes an optional since (epoch ms) and answers it from the directory listing: a name that parses as one of our ids and is older than the cutoff is skipped before it is ever opened.

Measured on this repo's real archive, through the compiled code with a counting read seam:

full history: 162 records, 162 reads
48h window:   4 records,   4 reads

Two edges, both deliberate

  • A name that does not parse as one of our ids is read as before. An id handed in from outside is not a date, and rejecting it unread would hide it from every caller that passes a window. There is a test for exactly this.
  • The id is allocated when a run is spawned; startedAt is written when it first opens its store. So the name can be the older of the two by the length of a spawn, and a caller filtering on startedAt sees a record leave the window at most that much early — against a window measured in days.

The history list, the boot reconcile and every by-id lookup pass no since and read the archive whole, as they must.

Verification

  • 1528/1528 pass.
  • Both new tests were validated by breaking the code they guard: with the filename filter neutered and the window cutoff replaced by 0, exactly those two fail and nothing else does.

…hive (#1607)

The cloud-work pass wants the settled web runs of the last 48 hours. It asked
the store for every archived run the project has ever had, parsed each one, and
then threw away everything outside the window — every ten minutes, forever,
while the archive only grows.

An archived run is filed as `<id>.json` and an id is the run's start time, so
the filename already dates the record. `listAgents` now takes an optional
`since` and answers it from the directory listing: a name that parses as one of
our ids and is older than the cutoff is skipped before it is opened.

On this repo today that is 162 reads per pass down to 4.

A name that does not parse as one of our ids is read as before — an id handed
in from outside is not a date, and rejecting it unread would hide it from every
caller that passes a window. The id is allocated when a run is spawned and
`startedAt` written when it first opens its store, so the name can be the older
of the two by the length of a spawn; a caller filtering on `startedAt` sees a
record leave the window at most that much early, against a window measured in
days.

The history list, the boot reconcile and every by-id lookup pass no `since` and
read the archive whole, as they must.

Closes #1607.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@suleimansh
suleimansh merged commit 3d216b4 into main Aug 21, 2026
2 checks passed
@suleimansh
suleimansh deleted the 1607-archive-window branch August 21, 2026 21:25
suleimansh added a commit that referenced this pull request Aug 22, 2026
…hive (#1607) (#1630)

The cloud-work pass wants the settled web runs of the last 48 hours. It asked
the store for every archived run the project has ever had, parsed each one, and
then threw away everything outside the window — every ten minutes, forever,
while the archive only grows.

An archived run is filed as `<id>.json` and an id is the run's start time, so
the filename already dates the record. `listAgents` now takes an optional
`since` and answers it from the directory listing: a name that parses as one of
our ids and is older than the cutoff is skipped before it is opened.

On this repo today that is 162 reads per pass down to 4.

A name that does not parse as one of our ids is read as before — an id handed
in from outside is not a date, and rejecting it unread would hide it from every
caller that passes a window. The id is allocated when a run is spawned and
`startedAt` written when it first opens its store, so the name can be the older
of the two by the length of a spawn; a caller filtering on `startedAt` sees a
record leave the window at most that much early, against a window measured in
days.

The history list, the boot reconcile and every by-id lookup pass no `since` and
read the archive whole, as they must.

Closes #1607.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloud work adoption: per-head git spawns every pass, and the daemon clock stretches under slow jobs

1 participant